<template>
    <div class="bg">
        <div class="box">
            <div class="login">
                Login
            </div>
            <div style="margin-top: 10px;">
                <el-tag>账号</el-tag>
                <el-input type="text" prefix-icon="el-icon-user" maxlength="11" v-model="account"></el-input>
            </div>
            <div style="margin-top: 10px;">
                <el-tag>密码</el-tag>
                <el-input type="password" prefix-icon="el-icon-lock" v-model="password"></el-input>
            </div>
            <div style="margin-top: 10px;">
                <el-button type="primary" @click="logins" plain style="width: 100%;">登录</el-button>
            </div>
        </div>
    </div>
</template>

<style>
body {
    padding: 0;
    margin: 0;

}

.bg {
    background-image: url("../../../public/img/1.png");
    background-position-y: -180px;
    height: 100vh;
    width: 100vw;
}

.box {
    width: 350px;
    border: 1px solid #eee;
    margin: auto;
    position: relative;
    top: 100px;
    padding: 8px;
    background-color: #fff;
    border-radius: 5px;
}

.login {
    height: 50px;
    line-height: 35px;
    text-align: center;
    font-size: 30px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    text-shadow: 3px 3px 3px #84ADEA;
    color: #fff;
}
</style>
<script>

import { login } from "@/api/login";
import { loading_close, loading_start } from "@/utils/message";
import { set_Cookie } from "@/utils/setCookie";



export default {
    data: function () {
        return {
            account: "19990921111",
            password: "0921"
        }
    },
    methods: {
        async logins() {
            loading_start("登录中....");

            const res = await login({
                account: this.account,
                password: this.password
            });
            loading_close();
            if (res.code === 0) {
                set_Cookie(res.data);
                //this.$router.push("/");
                location.href="/";
            } else {

                this.$message.error(res.message)
            }





            /* const res = await login({
                  account: this.account,
                  password: this.password
              })*/

            //异步变同步
            // if (res.code === 0) {

            //     set_Cookie(res.data);

            //     //登录成功
            //     this.$router.push('/');
            //     //this.$message.success(res.message)


            // } else {
            //     //登录失败
            //     this.$message.error(res.message)
            // }




        }
    }
}
</script>